package com.pureut.equipment.dubbo;

import com.pureut.equipment.api.RemoteEquimentService;
import com.pureut.equipment.service.InspectionItemPlanService;
import com.pureut.equipment.service.MaintenancePlanService;
import com.pureut.equipment.service.PatrolItemPlanService;
import com.pureut.equipment.service.SchedulingTaskService;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.ParseException;

/**
 * 设备dubbo
 */
@RequiredArgsConstructor
@DubboService
@Service
public class RemoteEquimentServiceImpl implements RemoteEquimentService {

    @Resource
    MaintenancePlanService maintenancePlanService;

    @Resource
    InspectionItemPlanService inspectionItemPlanService;

    @Resource
    PatrolItemPlanService patrolItemPlanService;

    @Resource
    SchedulingTaskService schedulingTaskService;



    /**
     * 根据保养计划开始时间和结束时间定时修改计划状态(定时任务调用)
     */
    @Override
    public void updateMaintenanceStatusByTime() throws ParseException {
        maintenancePlanService.updateMaintenanceStatusByTime();
    }

    /**
     * 根据点检计划开始时间和结束时间定时修改计划状态(定时任务调用)
     */
    @Override
    public void updateInspectionStatusByTime() throws ParseException {
        inspectionItemPlanService.updateInspectionStatusByTime();
    }

    /**
     * 根据巡检计划开始时间和结束时间定时修改计划状态(定时任务调用)
     */
    @Override
    public void updatePatrolStatusByTime() throws ParseException {
        patrolItemPlanService.updatePatrolStatusByTime();
    }

    /**
     * 触发生成工单
     */
    @Override
    public void generationWorkOrder() throws Exception {
        schedulingTaskService.generationWorkOrder();
    }
}
